package json.test;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.JsonObject;

public class People implements Serializable {

	private List<Annotation> annotations;
	private int age;
	private transient String name;
	private String sex;

	



	public List<Annotation> getAnnotations() {
		return annotations;
	}
	public void setAnnotations(List<Annotation> annotations) {
		this.annotations = annotations;
	}
	//	private HashMap<String, String> map;
	//	
	//	
	//	
	//	public HashMap<String, String> getMap() {
	//		return map;
	//	}
	//	public void setMap(HashMap<String, String> map) {
	//		this.map = map;
	//	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Override
	public String toString() {
		return "People [age=" + age + ", name=" + name + ", sex=" + sex + "]";
	}

	public static final String MASS_REQUEST_HEADER_SUFFIX1 = "</StatementName><Msg>";
	public static final String MASS_REQUEST_HEADER_SUFFIX2 = "</Msg></Statement>";
	public static void main(String[] args) {
		test3();
		//		test2();


		//		String aa = "<Statement><StatementName>RICA</StatementName><Msg></Msg></Statement>";
		//		int index = aa.indexOf(MASS_REQUEST_HEADER_SUFFIX1);
		//		System.out.println(index);
		//		String header = aa.substring(0, index + MASS_REQUEST_HEADER_SUFFIX1.length())
		//				+ MASS_REQUEST_HEADER_SUFFIX2;
		//		System.out.println(header);

	}
	private static void test2() {
		String aString  = "0/0/" + "office"+"/////" +"airline"+"/" 
				+ "agent" +"/"     +"level"  +"/"
				+ "curpos"+"//"    + "eyJnZHMiOiIiLCJvZmZTZXQiOjAsInNpemUiOjIwLCJhaXJsaW5lIjoiQ0EifQ==";

		System.out.println(aString);
	}
	private static void test1() {
		Gson gson = new Gson();
		People people = new People();
		people.setAge(24);
		people.setSex("男");
		people.setName("sunxj");
		//		HashMap<String, String> map = new HashMap<>();
		//	
		//		map.put("ID", "123");
		//		people.setMap(map);
		
		Annotation annotation = new Annotation();
		annotation.setName("id");
		annotation.setValue("123");

		ArrayList<Annotation> annotations = new ArrayList<>();
		annotations.add(annotation);
		people.setAnnotations(annotations);


		String json = gson.toJson(people);
		System.out.println(json);
		People fromJson = gson.fromJson(json, People.class);
		System.out.println(fromJson);
//		System.out.println(people.toString());
		JsonObject jsonObject = new JsonObject();
//		jsonObject.getObject
	}
	
	private static void test3() {
		Gson gson = new Gson();
		String json = "aa";
		
		People fromJson = gson.fromJson(json, People.class);
	}
	
	
}
